//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved

#include "pch.h"
#include "MeshObject.h"
#include "../DirectX/DirectXHelper.h"
#include "../Rendering/ConstantBuffers.h"

using namespace Microsoft::WRL;
using namespace DirectX;

MeshObject::MeshObject(ID3D11InputLayout* inputLayout):
	m_vertexBuffer(),
	m_indexBuffer(),
	m_inputLayout(inputLayout),
	m_vertexCount(),
	m_indexCount(),
	m_stride()
{
}

//D3D11_PRIMITIVE_TOPOLOGY_LINELIST
//D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
//D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
//--------------------------------------------------------------------------------

void MeshObject::Render(_In_ ID3D11DeviceContext *context, _In_ bool isFirstPass)
{
	//uint32 stride = sizeof(PNTVertex);
	uint32 offset = 0;

	context->IASetVertexBuffers(0, 1, m_vertexBuffer.GetAddressOf(), &m_stride, &offset);
	context->IASetIndexBuffer(m_indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
	context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	if (isFirstPass)
	{
		context->IASetInputLayout(m_inputLayout.Get());
	}
	context->DrawIndexed(m_indexCount, 0, 0);
}

//--------------------------------------------------------------------------------
